package cn.magic.basic.config;

import cn.magic.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
* @Description: 登录拦截配置类
* @Author: Mr.pc
* @Version: 1.0
* @Date:  2022/7/7 19:02
*/
@Configuration // 表示当前类是一个配置类
public class LoginConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**") // 设置拦截所有
                .excludePathPatterns("/login/**") // 放行登录路径
                .excludePathPatterns("/verifyCode/**") // 放行验证码相关接口
                .excludePathPatterns("/fastDfs/**") // 放行fastDfs相关接口
                .excludePathPatterns("/shop/settlement") // 放行店铺入驻接口
                .excludePathPatterns("/user/register/**");// 放行手机注册接口

    }

}
